package net.googlecode.morenko.task5.calculators;

import net.googlecode.morenko.task5.workers.Employee;
import net.googlecode.morenko.task5.workers.Worker;

/**
 * Calculates salary for employees.
 */
public class EmployeeCalculator implements Calculator {
    private final int TAX = 125;
    private final int HOURS_PER_MONTH = 170;

    /**
     * @see Calculator
     * @param person
     * @return calculated salary.
     */
    public int calculateSalary(Worker person) {
        Employee employee = (Employee)person;
        int salary = 0;
        if (employee.isPerHour()) {
            salary = HOURS_PER_MONTH * employee.getRate() - TAX;
        }
        else {
            salary = employee.getRate() * employee.getExperience() - TAX;
        }
        if (employee.isHaveBonus()) {
            salary += employee.getBonusAmount();
        }
        return salary;
    }
}
